<template name="components">
	<view>
		<scroll-view scroll-y class="page">
			<image src="/static/componentBg.png" mode="widthFix" class="response"></image>
			<view class="nav-list">
				<view hover-class='none' @click="goNav(item.name)" class="nav-li" navigateTo :class="'bg-'+item.color"
				 :style="[{animation: 'show ' + ((index+1)*0.2+1) + 's 1'}]" v-for="(item,index) in elements" :key="index">
					<view class="nav-title">{{item.title}}</view>
					<view class="nav-name">{{item.name}}</view>
					<text :class="'cuIcon-' + item.cuIcon"></text>
					<button open-type="getUserInfo" withCredentials="true"></button>
				</view>
			</view>
			<view class="cu-tabbar-height"></view>
		</scroll-view>
	</view>
</template>

<script>
	var _self;
	import {
		mapState,
		mapMutations
	} from 'vuex';	
	export default {
		computed: {
			...mapState(['userInfo', 'hasLogin', 'loginProvider', 'openid'])
		},
		data() {
			return {
				elements: [
					{
						title: '用户中心',
						name: 'usercenter',
						color: 'brown',
						cuIcon: 'newsfill'
					},
					{
						title: '积分列表',
						name: 'jifenliest',
						color: 'pink',
						cuIcon: 'list'
					},
					{
						title: '客户新增',
						name: 'customerinfo',
						color: 'purple',
						cuIcon: 'vipcard'
					},
					{
						title: '客户列表',
						name: 'customerlist',
						color: 'green',
						cuIcon: 'messagefill'
					},
					{
						title: '下级用户列表',
						name: 'xiajiayonghu',
						color: 'olive',
						cuIcon: 'album'
					},
					{
						title: '邀请用户',
						name: 'erweima',
						color: 'orange',
						cuIcon: 'timefill'
					},
				],
			};
		},
		onLoad() {
			_self = this;
			
		},
		methods:{
			...mapMutations(['login', 'logout', 'setOpenid', 'setProvider']),
			goNav(name){
				if(!this.hasLogin){
					uni.redirectTo({
						url:'/pageB/component/userinfo'
					})
				}else{
					uni.navigateTo({
						url:'/pageB/component/'+name
					})
				}
			}
		}
	}
</script>

<style>
	.page {
		height: 100vh;
	}
</style>
